﻿<%@ Page Culture="auto" UICulture="auto" Title="Additions attacher" Language="C#"
    MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="AdditionsAttacherPage.aspx.cs"
    Inherits="BM.Tools.WebControls.MForm.Example.Operations.AdditionsAttacherPage" %>

<%@ Register Assembly="BM.Tools.WebControls.MForm" Namespace="BM.Tools.WebControls.MForm.Controls"
    TagPrefix="mf" %>
<%@ Register Assembly="BM.Tools.WebControls.MForm" Namespace="BM.Tools.WebControls.MForm.Controls.Additions"
    TagPrefix="mfadd" %>
<%@ Register Assembly="BM.Tools.WebControls.MForm" Namespace="BM.Tools.WebControls.MForm.Controls.Modifiers"
    TagPrefix="mfmod" %>
<%@ Register TagPrefix="mftitle" Namespace="BM.Tools.WebControls.MForm.Controls.Titles"
    Assembly="BM.Tools.WebControls.MForm" %>
<asp:Content runat="server" ContentPlaceHolderID="Demonstration">
    <p>
        The error labels and bubble tooltips are added to all leaf items by specifying an
        AdditionsAttacher.
    </p>
    <mf:RootValidator runat="server" Display="None" ControlToValidate="Root1" />
    <mf:Root ID="Root1" runat="server">
        <Contents>
            <mf:Branch Name="Address" runat="server" Mode="Edit" meta:resourcekey="Address">
                <Contents>
                    <div class="ColLeft">
                        <mf:Leaf Name="Street" runat="server" Mode="Edit" meta:resourcekey="Address_Street">
                            <Additions>
                                <mfadd:Restriction runat="server" RestrictionType="MaxLength" Value="100"></mfadd:Restriction>
                            </Additions>
                        </mf:Leaf>
                        <mf:Leaf Name="HouseNumber" runat="server" Mode="Edit" meta:resourcekey="Address_HouseNumber">
                            <Additions>
                                <mfadd:Restriction runat="server" RestrictionType="MaxLength" Value="10"></mfadd:Restriction>
                            </Additions>
                        </mf:Leaf>
                        <mf:Leaf Name="FlatNumber" runat="server" Mode="Edit" meta:resourcekey="Address_FlatNumber">
                            <Additions>
                                <mfadd:Restriction runat="server" RestrictionType="MaxLength" Value="10"></mfadd:Restriction>
                            </Additions>
                        </mf:Leaf>
                    </div>
                    <div class="ColRight">
                        <mf:Leaf Name="PostCode" runat="server" Mode="Edit" meta:resourcekey="Address_PostCode">
                            <Additions>
                                <mfadd:Restriction runat="server" RestrictionType="Pattern" Value="\d{2}-\d{3}">
                                </mfadd:Restriction>
                            </Additions>
                        </mf:Leaf>
                        <mf:Leaf Name="Post" runat="server" Mode="Edit" meta:resourcekey="Address_Post">
                            <Additions>
                                <mfadd:Restriction runat="server" RestrictionType="MaxLength" Value="50"></mfadd:Restriction>
                            </Additions>
                        </mf:Leaf>
                        <mf:Leaf Name="City" runat="server" Mode="Edit" meta:resourcekey="Address_City">
                            <Additions>
                                <mfadd:Restriction runat="server" RestrictionType="MaxLength" Value="50"></mfadd:Restriction>
                            </Additions>
                        </mf:Leaf>
                    </div>
                </Contents>
            </mf:Branch>
        </Contents>
        <UriMappings>
            <mf:UriMapping Prefix="xs" Namespace="http://www.w3.org/2001/XMLSchema"></mf:UriMapping>
            <mf:UriMapping Prefix="" Namespace=""></mf:UriMapping>
        </UriMappings>        
        <Modifiers>
            <mfmod:AdditionsAttacher SelectorPath="//*" Filter="Leaf">
                <AdditionsTemplate>
                    <mfadd:ErrorLabelAddition ID="ErrorLabelAddition1" runat="server" />
                    <mfadd:BubbleTooltipAddition ID="BubbleTooltipAddition1" runat="server" />
                </AdditionsTemplate>
            </mfmod:AdditionsAttacher>
        </Modifiers>
    </mf:Root>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="Description" runat="server">
    <p>
        It is a common issue to add some extra functionality to a set of MForm items.
    </p>
    <p>
        In two of the already considered examples, the
        <asp:HyperLink runat="server" NavigateUrl="~/Operations/BubbleTooltipExamplePage.aspx"
            Text="Bubble tooltip addition" />
        and the
        <asp:HyperLink runat="server" NavigateUrl="~/Operations/ErrorLabelExamplePage.aspx"
            Text="Error Label addition" />
        controls were attached to all of the leaf items.
    </p>
    <p>
        In order to limit the amount of code and to avoid repetetiveness, the <code>AdditionsAttacher</code>
        modifier can be used. Instead of defining additions near each and every field, one
        <code>AdditionsAttacher</code> can be added to the Root control.
    </p>
    <div class="Section">
        <mftitle:TitleControl runat="server" Text="Properties" />
        <p>
            The <code>AdditionsAttacher</code> has the following properties:
        </p>
        <ul>
            <li><code>SelectorPath</code> - the path to all child items that should have the additions
                added </li>
            <li><code>Filter</code> - the filter to select only items of the selected type</li>
        </ul>
        <p>
            Besides that, the <code>AdditionsAttacher</code> contains an inner property <code>AdditionalsTemplate</code>
        </p>
        <p>
            In this property many <code>Addition</code> controls can be defined - all of them
            will be added to the items selected using the <code>SelectorPath</code> and <code>Filter</code>.
        </p>
    </div>
</asp:Content>
